import { createSlice } from '@reduxjs/toolkit'

const list = createSlice({
    name: 'list',
    initialState: {
        list: []
    },
    reducers: {
        addNum(state, action) {
            // state.list = action.payload
            let list1 = [...state.list]
            list1.push(action.payload)
            state.list = list1
            // console.log(state.list);
        },
        del(state, action) {
            // console.log(action.payload);
            let list1 = [...state.list]
            list1.splice(action.payload, 1)
            state.list = list1
        }

    },
})

export const { addNum, del } = list.actions

export default list.reducer